'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
    async List() {
        const { ctx } = this;
        const data = await this.app.mysql.select('parkList')
        ctx.body = {
            code: 1,
            data
        }
    }
    async detail() {
        const { ctx } = this;
        const { id } = ctx.query;
        console.log(id);

        const data = await this.app.mysql.get('parkList', { id })
        console.log(data);

        ctx.body = {
            code: 1,
            data
        }
    }
    async search() {
        const { ctx } = this;
        const { tt } = ctx.query;
        const sql = `SELECT*FROM parkList WHERE title LIKE '%${tt}%'`
        const data = await this.app.mysql.query(sql)
        ctx.body = {
            code: 1,
            data
        }
    }
}

module.exports = HomeController;